/**
 * This file is released under the GNU General Public License.
 * Refer to the COPYING file distributed with this package.
 *
 * Copyright (c) 2008-2009 WURFL-Pro srl
 */
package net.sourceforge.wurfl.core;

import net.sourceforge.wurfl.core.resource.ModelDevice;
import net.sourceforge.wurfl.core.resource.WURFLModel;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Abstract implementation of DeviceProvider.
 * 
 * @author WURFL-PRO SRL, Rome, Italy
 * @version $Id: AbstractDeviceProvider.java 1045 2009-03-09 15:52:53Z filippo.deluca $
 */
public abstract class AbstractDeviceProvider implements DeviceProvider {

	/** Log */
	private static final Log log = LogFactory.getLog(AbstractDeviceProvider.class);

	/** The model used as backend */
	protected final WURFLModel model;

	/**
	 * Build DeviceProvider by WURFLModel.
	 * 
	 * @param model
	 *            The wurflModel used as backend.
	 */
	public AbstractDeviceProvider(WURFLModel model) {
		this.model = model;
	}

	/**
	 * This method get a ModelDevice from WURFLModel.
	 * 
	 * @param deviceId
	 *            Th requested device identifier.
	 * @return a ModelDevice identified by deviceId.
	 */
	protected ModelDevice getModelDevice(String deviceId)
			throws DeviceNotDefinedException {

		ModelDevice modelDevice = model.getDeviceById(deviceId);

		return modelDevice;
	}

}
